<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>添加文头</title>
		<link href="css/table.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/openwindow.js"></script>
		<script type="text/javascript">
			function selectOrg(val){
				var url="orgByFlow.action?status="+val;
				openWindow(url,650,550);
			}
			function setValue(value,val){
				  var arr = eval(value);
				  var names = "";
				  var ids = "";
				  for(i=0;i<arr.length;i++){
				    ids =  ids + "," + arr[i].value;
				    names = names + "," + arr[i].name;
				  }
				  if(names.length>0){
				    names = names.substring(1);
				    ids =  ids.substring(1);
				  }
				  document.getElementById(val+"names").value=names;
				  document.getElementById(val+"ids").value=ids;
			}
			function getOldValue(val){
				  var ids=document.getElementById(val+"ids").value;
				  var names=document.getElementById(val+"names").value;
				    var array="";
				  if(ids!=''&&ids!='null'){
				  var idarray=ids.split(",");
				  var namearray=names.split(",");
				  for(var i=0;i<idarray.length;i++){
				  		if(i==0){
				  			array+="{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  		}else{
				  	      array+=",{\"value\":"+idarray[i]+",\"name\":\""+namearray[i]+"\"}";
				  	   } 
				  }
				  }
				  return array;
			}
			

	function saveDispatcherTop(){
		var title=$("#title").val();
		var shortName=$("#shortName").val();
		var onames=$("#onames").val();
		if($.trim(title)==''||$.trim(title)=='null'){
			alert('文头不能为空！')
			return;
		}
		if($.trim(shortName)==''||$.trim(shortName)=='null'){
			alert('简称不能为空！')
			return;
		}
		if($.trim(onames)==''||$.trim(onames)=='null'){
			alert('适用范围不能为空！')
			return;
		}
		$.post("updateDispatcherTop.action",$("form").serialize(),function(data){
					if(data=='success'){
						alert("修改成功");
						window.close();
						var currentPage=$("#currentPage").val();
						window.parent.opener.page(currentPage);
					}else{
						alert("修改失败！");
					}
				});
	}
</script>
	</head>
	<body>
	<input type="hidden" id="currentPage" value="${currentPage}">
		<table align="center" border="0" cellpadding="0" cellspacing="0"
			width="98%">
			<tbody>
				<tr>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
					<td style="background: url('image/wsoa_window_002.gif');">
						<table border="0" cellpadding="0" cellspacing="0">
							<tbody>
								<tr>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"
										width="10">
										<img src="image/center_19.gif">
										<td>工作流程 &gt; 流程管理 &gt; 文头设置&gt;添加</td>
									<td align="center"
										style="background: url('image/wsoa_window_002.gif');"></td>
									<td></td>
								</tr>
							</tbody>
						</table>
					</td>
					<td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
				</tr>
				<tr>
					<td style="background: url('image/wsoa_window_010.gif');" width="1">
						&nbsp;
					</td>
					<td>
					
						<form name="saveFlowTypeForm" id="saveFlowType" method="post" action="">
						<input type="hidden" name="dispatcherTop.id" value="${dispatcherTop.id}">
							<span class="font12"> </span>
							<table style="width: 99%;" align="center">
								<tbody>
									<tr>
										<td>
											<table style="width: 100%;" class="table5 bgcolor5"
												align="center">
												<tbody>
												<tr>
													<td class="table5 bgcolor5" align="right" width="100">文头名称</td>
													<td class="table5" align="left"><input name="dispatcherTop.name" value="${dispatcherTop.name}" id="title" maxlength="50"   title="该输入项的最大长度是50" style="width: 90%" type="text"></td>
												</tr>
												<tr>
													<td class="table5 bgcolor5" align="right" width="100">简称</td>
													<td class="table5" align="left"><input name="dispatcherTop.shortName" value="${dispatcherTop.shortName}" id="shortName" maxlength="50"   title="该输入项的最大长度是50" style="width: 90%" type="text"></td>
												</tr>
												<tr>
													<td class="table5 bgcolor5" align="right" width="100">适用范围 </td>
													<td class="table5" align="left">
													<textarea readonly="readonly" id="onames" style="height: 30px; width: 470px;" name="orgNames">${dispatcherTop.orgName}</textarea>
										           <input type="hidden" id="oids"  name="orgId" value="${dispatcherTop.orgIds}">
												</td>
												</tr>
												<tr>
													<td width="60px"></td>
													<td>
														<a href="javascript:selectOrg('o')">选择部门</a>
													</td>
												</tr>
												</tbody>
											</table>
										</td>
									</tr>
								</tbody>
							</table>
							<table style="width: 99%;" align="center">
								<tbody>
									<tr>
										<td align="center">
											<input accesskey="t" value="提交" style="background: url('image/button_02.gif');" onClick="saveDispatcherTop();" class="button_02" type="button">
											<input class="button_02" value="取消" accesskey="c" style="background: url('image/button_02.gif');" onClick="window.close();" type="button">
										</td>
									</tr>
								</tbody>
							</table>
						</form>
					</td>
					<td style="background: url('image/wsoa_window_006.gif');" width="1">
						&nbsp;
					</td>
				</tr>
				<tr>
					<td height="1" width="1">
						<img src="image/wsoa_window_009.gif" height="16" width="14">
					</td>
					<td style="background: url('image/wsoa_window_008.gif');"
						height="1"></td>
					<td height="1" width="1">
						<img src="image/wsoa_window_007.gif" height="16" width="12">
					</td>
				</tr>
			</tbody>
		</table>
	</body>
</html>